<?php

基于 bootstrap-0-入口.php

'Illuminate\Foundation\Bootstrap\RegisterFacades' 的功能就是注册 Facades。

\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\RegisterFacades.php
    namespace Illuminate\Foundation\Bootstrap;

    use Illuminate\Foundation\AliasLoader;
    use Illuminate\Support\Facades\Facade;
    use Illuminate\Contracts\Foundation\Application;

    class RegisterFacades
    {
        /**
         * Bootstrap the given application.
         *
         * @param  \Illuminate\Contracts\Foundation\Application  $app
         * @return void
         */
        public function bootstrap(Application $app)
        {
            Facade::clearResolvedInstances();

            Facade::setFacadeApplication($app);

            AliasLoader::getInstance($app->make('config')->get('app.aliases', []))->register();
        }
    }

\vendor\laravel\framework\src\Illuminate\Foundation\AliasLoader.php
    private function __construct($aliases)
    {
        $this->aliases = $aliases;
    }
    public function load($alias)
    {
        if (isset($this->aliases[$alias])) {
            return class_alias($this->aliases[$alias], $alias);
            /*
            class_alias ( string $original , string $alias [, bool $autoload = TRUE ] ) : bool
            基于用户定义的类 original 创建别名 alias。 这个别名类和原有的类完全相同。

            original
            原有的类。

            alias
            类的别名。

            autoload
            如果原始类没有加载，是否使用自动加载（autoload）。

            成功时返回 TRUE， 或者在失败时返回 FALSE。

            那么，本质就是注册了类加载机制。当加载 App 时，根据类加载机制，会执行这里的 load 方法。
            此时，参数 $alias 就是 'App'；
            然后从 $this-aliases 中找，找到了，那么使用 class_alias 函数导致此别名对应的真实存在的类 Illuminate\Support\Facades\App。
            */
        }
    }
    public function register()
    {
        if (! $this->registered) {
            $this->prependToLoaderStack();

            $this->registered = true;
        }
    }
    protected function prependToLoaderStack()
    {
        spl_autoload_register([$this, 'load'], true, true);
    }
$this->aliases 就是 \config\app.php 中的数组：
    'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        'Blade' => Illuminate\Support\Facades\Blade::class,
        'Bus' => Illuminate\Support\Facades\Bus::class,
        'Cache' => Illuminate\Support\Facades\Cache::class,
        'Config' => Illuminate\Support\Facades\Config::class,
        'Cookie' => Illuminate\Support\Facades\Cookie::class,
        'Crypt' => Illuminate\Support\Facades\Crypt::class,
        'DB' => Illuminate\Support\Facades\DB::class,
        'Eloquent' => Illuminate\Database\Eloquent\Model::class,
        'Event' => Illuminate\Support\Facades\Event::class,
        'File' => Illuminate\Support\Facades\File::class,
        'Gate' => Illuminate\Support\Facades\Gate::class,
        'Hash' => Illuminate\Support\Facades\Hash::class,
        'Lang' => Illuminate\Support\Facades\Lang::class,
        'Log' => Illuminate\Support\Facades\Log::class,
        'Mail' => Illuminate\Support\Facades\Mail::class,
        'Notification' => Illuminate\Support\Facades\Notification::class,
        'Password' => Illuminate\Support\Facades\Password::class,
        'Queue' => Illuminate\Support\Facades\Queue::class,
        'Redirect' => Illuminate\Support\Facades\Redirect::class,
        'Redis' => Illuminate\Support\Facades\Redis::class,
        'Request' => Illuminate\Support\Facades\Request::class,
        'Response' => Illuminate\Support\Facades\Response::class,
        'Route' => Illuminate\Support\Facades\Route::class,
        'Schema' => Illuminate\Support\Facades\Schema::class,
        'Session' => Illuminate\Support\Facades\Session::class,
        'Storage' => Illuminate\Support\Facades\Storage::class,
        'URL' => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View' => Illuminate\Support\Facades\View::class,

    ],
